﻿using UnityEngine;
using System.Collections;

public class PlaybackKit : MonoBehaviour
{
    public UIInput input;

    public UIInput serverId;

    void Start()
    {
#if !UNITY_EDITOR
        gameObject.SetActive(false);
#endif
    }

    public void OnFightButtonClick()
    {
        AskPlaybackBattleInfo(input.value, int.Parse(serverId.value));
    }

    public void AskPlaybackBattleInfo(string fightId, int _serverId)
    {
        ProtoBuf.Message.CSFightPlayback msg = new ProtoBuf.Message.CSFightPlayback();
        msg.fightId = fightId;
        msg.serverId = _serverId;
        NetAPI.SendHttp(ProtoBuf.Message.OpDefine.CSFightPlayback, msg, AskPlaybackBattleInfoCallback);
    }

    void AskPlaybackBattleInfoCallback(NetWork.Packets.Packet pack, bool bSuccess)
    {
        if (bSuccess)
        {
            ProtoBuf.Message.SCFightPlayback msg = pack.kBody as ProtoBuf.Message.SCFightPlayback;
            StaticData.lastBattleEndMsg = msg;
            StaticData.curBattleData.SetPlaybackData(msg);
            ToBattle();
        }
    }

    void ToBattle()
    {
        ManagerController.Instance.RoomToBattleRecruit();
    }


}